package ws;

import java.io.IOException;
import java.util.Date;

import interfaces.ClientInterface;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

@Path("")
public class ClientRest implements ClientInterface{
	
	@GET
	@Produces(MediaType.APPLICATION_JSON)
	@Path("/get_lines")
	@Override
	public String getAllLines() {
		return new Service().getAllLines();
	}
	
	@GET
	@Produces(MediaType.APPLICATION_JSON)
	@Path("/get_pontos/{line}")
	@Override
	public String getInfo(@PathParam("line") int line) {
		return new Service().getRoute(line);
	}
	
	@GET
	@Produces("application/json")
	@Path("/get_linhas/{line}")
	@Override
	public String getStreets(@PathParam("line") int line) {
		String lineRoute = null;
		try {
			lineRoute = new Service().extractLineRoute(line);
		} catch (IOException e) {
			e.printStackTrace();
		}
		return lineRoute;
	}
	
	@GET
	@Produces("application/json")
	@Path("/get_linesByCoordenates/{latiO}/{longO}/{latiF}/{longF}")
	@Override
	public String getLinesCoordenates(@PathParam("latiO") double latiO, @PathParam("longO")double longO, @PathParam("latiF")double latiF, @PathParam("longF")double longF) {
		// TODO Auto-generated method stub
		return new Service().getLinesCoordenates(latiO, longO, latiF, longF);
	}
	
	@GET
	@Produces("application/json")
	@Path("/get_linesByTerminal/{latiO}/{longO}/{latiF}/{longF}")
	@Override
	public String getLinesTerminal(@PathParam("latiO") double latiO, @PathParam("longO")double longO, @PathParam("latiF")double latiF, @PathParam("longF")double longF) {
		// TODO Auto-generated method stub
		return new Service().getLinesTerminal(latiO, longO, latiF, longF);
	}

//	@GET
//	@Produces("application/json")
//	@Path("/get_linhas/{x}/{y}")
	@Override
	public String getLines(@PathParam("x") int x, @PathParam("y") int y){
		String res = "";
		return res;		
	}
	
	@GET
	@Produces(MediaType.APPLICATION_JSON)
	@Path("/configDB")
	public String configDB(){
		KmlOperation ko = new KmlOperation();
		ko.saveAllLineBD();
		return "Pronto....";
	}

	@Override
	public boolean isBaseUpdated(Date myBaseDate) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public String getUpdate(Date myBaseDate) {
		// TODO Auto-generated method stub
		return null;
	}

}
